<?php

class PhpFox_Mod_Video_ComponentMain extends BaseComponent
{
    function process()
    {
    	App::checkUserAccess('video', array('full', 'read_only'));

    	$oSrvVideo = &$this->_oModule->getService('Video');
    	$oReq = &App::getRequest();

		if ( $oReq->get('dhotvideo') && App::isStaff(true) )
		{
			$oSrvVideo->removeHotVideo();
			App::gotoUrl('public.videos', array(), App::format('Mod_Video.hot_video_removed'), false);
		}

    	if ( $iHotVidId = App::getParam('vid_hot_video') )
    	{
    		$oSrvVideo = &$this->_oModule->getService('Video');
    		$aRandVideo = $this->oDatabase->getRow("SELECT v.vid_id, v.vid_title, v.vid_url, v.vid_type, v.stream_id, v.vid_time, u.user FROM
    			". App::getT('videos') ." AS v
    			JOIN ". App::getT('user') ." AS u ON(v.vid_userid = u.id)
    			WHERE v.vid_id = '". $iHotVidId ."'");
		}

    	$aItems = $this->oDatabase->getRows("SELECT list_id, list_name, list_total FROM ". App::getT('videos_list') ." ORDER BY list_name");

		$this->oTpl->assign(array
		(
			'aRand' => (isset($aRandVideo) ? $aRandVideo : ''),
			'vidUrl' => (isset($aRandVideo) ? $oSrvVideo->displayVideo($aRandVideo) : ''),
			'aCats' => $aItems,
		));

		return $this->oTpl->fetch('Main.html');
    }
}

?>